using System.Collections.Generic;
using System.Linq;

namespace Quiki.Querying
{
    public class CategoryQuerySpecification : IQuerySpecification
    {
        public CategoryQuerySpecification(string categoryName)
        {
            this.categoryName = categoryName;
        }

        public string CategoryName
        {
            get { return categoryName; }
        }

        public IEnumerable<WikiDocument> Filter(IEnumerable<WikiDocument> documents)
        {
            return from doc in documents
                   where doc.Categories.Contains(categoryName)
                   select doc;
        }

        private readonly string categoryName;
    }
}